#if !defined(_GenericAlgebra_test_)
#define _GenericAlgebra_test_

#include <src/math/Operators/GenericAlgebra.h>
/*! exemple of basic algebra operator implementation.
	
	This class provide a basic example of operator algebra described by OS_Generic_Algebra.
*/
template<class A,class R >
struct double_function : public OS_Generic_Algebra<A,R>
	{
		typedef OS_Generic_Algebra<A,R>	Base;
		typedef Base	Base_Cast;
		double_function(){};
		double_function(const Base &first) : Base(first)
		{};
//! Copy Ctor
	double_function(const double_function & from) :  Base(from) {
	};
	virtual ~double_function(){};
//! A factory type function : return Create_Instance_helper<double_function>();
	virtual smart_ptr_type Create_Instance() const {
		return Create_Instance_helper<double_function>();
	};
//! equality operator
	virtual bool equals (const Base_Cast& from) const 
	{
		return Base::operator==(from);
	}

	virtual void output (std::ostream& o) const {
		o<<"double_function";
		if (first_)
			first_->output(o);
		
	};
};

template<class A,class R>
struct x_2_function : public double_function<A,R>
{
//! the base class
	typedef double_function		Base;
//! Default Ctor
	x_2_function() { 
	};
//! Copy Ctor
	x_2_function(const x_2_function & from) : Base(from) {
	};
//! Ctor from base class
	x_2_function(const Base & from) : Base(from) {
	};
	virtual ~x_2_function(){};
//! implementation of the evaluation function : return data*data
	virtual result_type operator()(argument_type data) const {
		return data*data;
	};
//! A factory type function : return Create_Instance_helper<x_2_function>();
	virtual smart_ptr_type Create_Instance() const {
		return Create_Instance_helper<x_2_function>();
	};
	virtual void output (std::ostream& o) const {
		o<<"x^2";
		if (first_)
			first_->output(o);
		
	};
//! equality operator
	virtual bool equals (const double_function& from) const 
	{
		return Base::operator==(from);
	}


};
template<class A,class R>
struct x_3_function : public double_function<A,R>
{
//! the base class
	typedef double_function		Base;
//! Default Ctor
	x_3_function() {
	};
//! Ctor from base class
	x_3_function(const double_function & from) : Base(from) {
	};
//! Copy Ctor
	x_3_function(const x_3_function & from) : Base(from) {
	};
	virtual ~x_3_function(){};
//! implementation of the evaluation function : return data*data*data
	virtual result_type operator()(argument_type data) const {
		return data*data*data;
	};
//! A factory type function : return Create_Instance_helper<x_3_function>();
	virtual smart_ptr_type Create_Instance() const {
		return Create_Instance_helper<x_3_function>();
	};
	virtual void output (std::ostream& o) const {
		o<<"x^3";
		if (first_)
			first_->output(o);
		
	};
//! equality operator
	virtual bool equals (const double_function& from) const 
	{
		return Base::operator==(from);
	}
};

void GenericAlgebra_test();

#endif